package com.xkdx.guangguang.fragment.my.setup;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class UpdateVersionModule extends AbsModule {
	public Startup startup;

	@Override
	public void parseData() throws Exception {
		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("checkUpdate")) {
					startup = parseCheckUpdate(jsonObj.getJSONObject("Content"));
				}

			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	private Startup parseCheckUpdate(JSONObject person) throws Exception{
		Startup startup = new Startup();
		try {
			if (person == null) {
				return null;
			}
			JSONObject stut = (JSONObject) person.get("Result");
			JSONObject detail = stut.getJSONObject("DetailInfo");

			startup.setClientDownloadUrl(detail.getString("ClientDownloadUrl"));
			startup.setClientLatestVersion(detail.getString("ClientLatestVersion"));
			startup.setClientUpdateMemo(detail.getString("ClientUpdateMemo"));
			startup.setClientUpdate(detail.getString("ClientUpdate"));

		} catch (Exception e) {
			throw e;
		}
		return startup;
	}

	public class Startup {
		String SystemTime;
		String CityUpdate;
		String ClientUpdate;
		String ClientLatestVersion;
		String ClientDownloadUrl;
		String ClientUpdateMemo;

		public String getSystemTime() {
			return SystemTime;
		}

		public void setSystemTime(String systemTime) {
			SystemTime = systemTime;
		}

		public String getCityUpdate() {
			return CityUpdate;
		}

		public void setCityUpdate(String cityUpdate) {
			CityUpdate = cityUpdate;
		}

		public String getClientUpdate() {
			return ClientUpdate;
		}

		public void setClientUpdate(String clientUpdate) {
			ClientUpdate = clientUpdate;
		}

		public String getClientLatestVersion() {
			return ClientLatestVersion;
		}

		public void setClientLatestVersion(String clientLatestVersion) {
			ClientLatestVersion = clientLatestVersion;
		}

		public String getClientDownloadUrl() {
			return ClientDownloadUrl;
		}

		public void setClientDownloadUrl(String clientDownloadUrl) {
			ClientDownloadUrl = clientDownloadUrl;
		}

		public String getClientUpdateMemo() {
			return ClientUpdateMemo;
		}

		public void setClientUpdateMemo(String clientUpdateMemo) {
			ClientUpdateMemo = clientUpdateMemo;
		}

	}

}
